function ismobile() {
    //判断访问终端
    var browser = {
        versions: function () {
            var u = navigator.userAgent, app = navigator.appVersion;
            return {
                trident: u.indexOf('Trident') > -1, //IE内核
                presto: u.indexOf('Presto') > -1, //opera内核
                webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
                mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
                iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                iPad: u.indexOf('iPad') > -1, //是否iPad
                webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
                qq: u.match(/\sQQ/i) == " qq" //是否QQ
            };
        }(),
        language: (navigator.browserLanguage || navigator.language).toLowerCase()
    };

    if (browser.versions.mobile == true) {

        if (browser.versions.iPhone == true) {

            return '1';

        } else if (browser.versions.android == true) {

            return '0';
        }
    } else {

    }
}

var $goods_id, $uid, token, address, serverid, oldStartTime, oldEndTime;

//serviceId(74, 110108, "030BAFAB-D049-FE0D-3490-5EB3DEDC27D3", "201809261100", "201809261130");

var isMobile = ismobile();

function getId() {

    if (isMobile == 1) {

        CallManPowerDetailsModel.jsCallOCWithSendId();

    } else if (isMobile == 0) {

        window.android.getAndroidId("okok");
    }
}

if (isMobile == 0) {

    window.android.getAndroidId("okok");

}

function WebViewDidFinishLoad() {

    var message = {

        "VcWay": "SendId"
    };

    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage(message);
}

function receive_android_projectid(k) {

    var obj = $.parseJSON(k);

    address = obj.addressID;

    token = obj.TOKEN;

    $goods_id = obj.goods_id;

    $uid = obj.uid;

    oldStartTime = obj.startDate;

    oldEndTime = obj.endDate;

    serviceId($goods_id, address, token, oldStartTime, oldEndTime);
}

function receiveiOSVcData(i) {

    var obj = $.parseJSON(i);

    address = obj.addressID;

    //alert(address)

    token = obj.TOKEN;

    $goods_id = Number(obj.goods_id);//保存goods_id

    $uid = obj.uid;

    oldStartTime = obj.startDate;

    oldEndTime = obj.endDate;

    serviceId($goods_id, address, token, oldStartTime, oldEndTime);

}

function myAjax(goods_id, address, token, oldStartTime, oldEndTime) {

    $.ajax({

        type: "POST",

        url: url + "users/fourModel",

        dataType: "json",

        data: {"goods_id": goods_id, "url": "product/goods/webInfo"},

        success: function (result) {

            //console.log(result)

            if (result.codes == "200") {

                var html = template("swiperTpl", result);

                $("body").html(html);

                if (isiphoneX) {

                    $("#footer").css("padding-bottom", "0.484rem");

                    $(".remark").css("padding-bottom", "2.384rem")
                }

                if (oldStartTime && oldEndTime) {

                    $(".startDate").val(timeFormat(oldStartTime));

                    $(".endDate").val(timeFormat(oldEndTime));
                }

                getParams();

            }

            //设置标签展开收起
            //var lll = $(".tag").children("li").length;
            //if (lll > 5) {
            //    $(".show").css("display", "block");
            //    $(".show").click(function () {
            //        if ($(".show").hasClass("show_no")) {//  点击展开  换图标 shang
            //            $(".tag").css("height", "auto");
            //            $(this).removeClass("show_no");
            //            $(this).addClass("show_top")
            //        } else {
            //            $(".tag").css("height", 1 + "rem");//换图标 xia 默认
            //            $(this).removeClass("show_top");
            //            $(this).addClass("show_no");
            //        }
            //    });
            //}


            var starts = result.data.person_star;

            if (starts > 0) {//五星好评

                if (starts > 5) {

                    starts = 5;

                    for (var i = 0; i < starts; i++) {

                        $("#star_in b").eq(i).removeClass("no").addClass("yes");
                    }
                } else {

                    for (var i = 0; i < starts; i++) {

                        $("#star_in b").eq(i).removeClass("no").addClass("yes");
                    }
                }
            }
            new Swiper('.swiper-container', { //  初始化轮播图

                direction: 'horizontal',

                loop: true,

                autoplay: 4000,

                // 如果需要分页器
                pagination: '.swiper-pagination',

                autoplayDisableOnInteraction: false
            });

            //如果返回的条数大于2,如果小于2大于0，如果小于等于0
            //var  goodsMealLength=result.data.goods_meal.length;
            //if(goodsMealLength>0){
            //    var spanLength=$(".label span");
            //    if(spanLength.length>3){
            //        for(var i=3;i<spanLength.length;i++){
            //            var spanStyle=spanLength[i];
            //            spanStyle.style.display="none";
            //        }
            //    }
            //}

            if (result.data.goods_meal[0].store_status == 100) {

                $(".setMeal").find("li").eq(0).addClass("active");//默认第一项有active类   套餐
            }

            var timeLong = result.data.base_time_long_config;

            if (timeLong.length && timeLong[0].time_long_info.select_status == 100) {

                $(".langTime").find("li").eq(0).addClass("active");//                服务时长
            }
            result.data.goods_meal.forEach(function (item, i) {

                if (item.store_status == 200) {

                    $(".setMeal").find("li").eq(i).addClass("op");
                }
            });
            result.data.base_time_long_config.forEach(function (item, i) {

                if (item.time_long_info.select_status == 200) {

                    $(".langTime").find("li").eq(i).addClass("op");//
                }
            });
            if (result.data.goods_meal.length > 3) {

                $(".meal>span").css("width", "1.3rem")
            }

            $(".setMeal").on("click", "li", function () {  //套餐

                $(".setMeal li").removeClass("active");

                $(this).addClass("active");

                if ($(this).hasClass("op")) {

                    $(this).removeClass("active")
                }
                getParams();
            });

            $(".langTime").on("click", "li", function () {//时长

                $(".langTime li").removeClass("active");

                $(this).addClass("active");

                if ($(this).hasClass("op")) {

                    $(this).removeClass("active")
                }

                var type = $(this).attr("data-type");


                getParams();

                $(".tagP span").html(type);

                isCollect($uid, $goods_id, token);

                //getParams();

            });


            $(".date").on("click", ".startDate", function () {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({"VcWay": "StartDate"});

                } else if (isMobile == 0) {

                    window.android.startShowToast("Start");
                }
            });

            $(".date").on("click", ".endDate", function () {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({"VcWay": "EndDate"});

                } else if (isMobile == 0) {

                    window.android.endShowToast("end");
                }
            });


            $(".message").on("click", function () {//点击人员信息跳转至人员信息页

                var json = {"goods_id": $goods_id};

                if (isMobile == 1) {

                    var message = {

                        "VcData": json,

                        "VcName": "ManPowerInformation",

                        "VcWay": "PushVCName"
                    };

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage(message);

                } else if (isMobile == 0) {

                    window.android.jumpToPersonMsg(JSON.stringify(json));
                }
            });

            if (serverid != null) {

                $(".dangqi").on("click", function () {//点击档期跳转到档期页

                    var json = {"goods_id": $goods_id, "uid": $uid, "uu_number": 1, "serverid": serverid};

                    if (isMobile == 1) {

                        window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                            "VcData": json,
                            "VcName": "ManPowerCalender",
                            "VcWay": "PushVCName"

                        });


                    } else if (isMobile == 0) {

                        window.android.jumpToPersonCalader(JSON.stringify(json));
                    }
                })

            } else {
                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": "没有相应供应商",
                        "VcWay": "ShowMessage"
                    });

                } else if (isMobile == 0) {

                    window.android.toastMsg("没有相应供应商");
                }
            }
            $(".appraise").on("click", function () {//点击累计评价跳转至累计评价页

                var json = {"goods_id": $goods_id};

                if (isMobile == 1) {

                    var message = {

                        "VcData": json,

                        "VcName": "ManPowerEvaluation",

                        "VcWay": "PushVCName"
                    };

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage(message);

                } else if (isMobile == 0) {

                    window.android.jumpToAppraise(JSON.stringify(json));
                }
            });
            $("#heart").on("touchstart", function () {//点击收藏，再次点击取消收藏

                var className = $(this).attr("class");

                if (className == "heart") {//如果是未收藏 点击就收藏 告诉后台

                    collect($uid, $goods_id, 100, $(this), token)

                } else if (className == "heartHover") {//已收藏，点击就取消收藏 告诉后台

                    collect($uid, $goods_id, 200, $(this), token)
                }
            });
            $(".cart").on("touchstart", function () {//点击购物车，弹出小黑框添加成功

                var StartTime = $(".date .startDate").val().replace(/-/g, "/");

                var EndTime = $(".date .endDate").val().replace(/-/g, "/");

                var sumTotal = $("#footer .sub").html();

                var goodsPrice = $(".langTime  li.active").data("type");

                var meal = ($(".setMeal li.active").attr("id"));

                var addr = address;

                var time_long_id = $(".langTime li.active").attr("id") || 0;

                var timestampStart = Date.parse(new Date(StartTime)) / 1000;//开始时间    时间戳

                var timestampEnd = Date.parse(new Date(EndTime)) / 1000;    //结束时间    时间戳

                var timestampNow = Date.parse(new Date()) / 1000;          //当前时间     时间戳

                //开始时间要大于当前时间  结束时间只能大于开始时间小于3个月

                var timeLag = timestampEnd - timestampStart;

                var timeDistance = (mGetDate(1) + mGetDate(2) + mGetDate(3)) * 24 * 60 * 60;

                if (timeFormatDate(StartTime) && timeFormatDate(EndTime)) {

                    if (StartTime == "开始时间" || EndTime == "结束时间") {

                        if (StartTime == "开始时间") {

                            if (isMobile == 1) {

                                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                                    "VcData": "请选择开始时间",
                                    "VcWay": "ShowMessage"
                                });

                            } else if (isMobile == 0) {

                                window.android.toastMsg("请选择开始时间");

                            }
                            return false;
                        }
                        if (EndTime == "结束时间") {

                            if (isMobile == 1) {

                                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                                    "VcData": "请选择结束时间",
                                    "VcWay": "ShowMessage"
                                });

                            } else if (isMobile == 0) {

                                window.android.toastMsg("请选择结束时间");

                            }
                            return false;
                        }
                    } else if (StartTime >= EndTime) {

                        if (isMobile == 1) {

                            window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                                "VcData": "结束时间必须大于开始时间",
                                "VcWay": "ShowMessage"
                            });

                        } else if (isMobile == 0) {

                            window.android.toastMsg("结束时间必须大于开始时间");

                        }
                        return false;
                    } else if (timeLag > timeDistance) {

                        if (isMobile == 1) {

                            window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                                "VcData": "结束时间不能大于开始时间90天",
                                "VcWay": "ShowMessage"
                            });

                        } else if (isMobile == 0) {

                            window.android.toastMsg("结束时间不能大于开始时间90天");

                        }
                        return false;

                    }
                    else {

                        if (!goodsPrice) {

                            if (isMobile == 1) {

                                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                                    "VcData": "服务时长不能为空",
                                    "VcWay": "ShowMessage"
                                });

                            } else if (isMobile == 0) {

                                window.android.toastMsg("服务时长不能为空");

                            }

                        } else {

                            addCar($uid, $goods_id, 1, timeFormatDate(StartTime), timeFormatDate(EndTime), goodsPrice, sumTotal.slice(1), meal, addr, token, time_long_id)
                        }


                    }
                }
            });
            //点击立即购买跳转至下订单页
            if (serverid != null) {

                var isRun = true;

                $(".button").on("click", function () {

                    if (isRun) {

                        runa();

                        isRun = false;

                    }
                    setTimeout(function () {

                        isRun = true;

                    }, 1500);//点击后相隔多长时间可执行

                });
            } else {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": "没有相应供应商",
                        "VcWay": "ShowMessage"
                    });

                } else if (isMobile == 0) {

                    window.android.toastMsg("没有相应供应商");
                }
            }
        },
        error: function (info) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "请检查网络",
                    "VcWay": "ShowMessage"
                });

            } else if (isMobile == 0) {

                window.android.toastMsg("请检查网络");
            }
        }
    });
}


function receiveiOSStartDate(a) {

    $(".startDate").val(a);

    getParams()
}
function receive_android_startDate(k) {

    $(".startDate").val(k);

    getParams()
}
function receiveiOSEndDate(a) {

    $(".endDate").val(a);

    getParams()
}
function receive_android_endDate(k) {

    $(".endDate").val(k);

    getParams()
}
//计算价格
function Amount(start_time, end_time, price) {

    var diffSecond = (end_time - start_time) / 1000;

    var diffHour = diffSecond / 3600;

    var diffDay = Math.floor(diffSecond / (24 * 3600));

    var remainderMoney = 0;

    if (diffHour > 24) {

        var remainderHour = Math.ceil(diffHour % 24);

        if (remainderHour > 8) {

            diffDay += 1;

        } else {

            remainderMoney = (price / 8) * remainderHour;

        }

        return Number((diffDay * price + remainderMoney )).toFixed(2);

    } else {

        return Number(price).toFixed(2);
    }
}
// 套餐  时间 放在一个类里面 计算价格   时间要时间戳
function getParams() {

    var mealPrice = Number($(".langTime li.active").data("type")) || Number($(".price").html());

    var startTime = $(".startDate").val();

    var endTime = $(".endDate").val();

    var timestamp1 = Date.parse(new Date(startTime.replace(/-/g, "/")));//将开始时间转换为时间戳

    var timestamp2 = Date.parse(new Date(endTime.replace(/-/g, "/")));//将结束时间转换为时间戳


    if (timestamp1 && timestamp2) {

        var totalAmount = Amount(timestamp1, timestamp2, mealPrice);

        $(".sub").html("￥" + totalAmount);
    }
}
//格式化时间
function timeFormatDate(timeStamp) {

    var tmpTime = Date.parse(new Date(timeStamp));

    Date.prototype.format = function (format) {
        var date = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S+": this.getMilliseconds()
        };
        if (/(y+)/i.test(format)) {
            format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
        }
        for (var k in date) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length == 1
                    ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
            }
        }
        return format;
    }

    var newDate = new Date();
    newDate.setTime(tmpTime);
    return newDate.format('yyyyMMddhhmm');
}
//格式化时间
function timeFormat(time) {//201712271200
    var y = time.substring(0, 4);
    var m = time.substring(4, 6);
    var d = time.substring(6, 8);
    var h = time.substring(8, 10);
    var s = time.substring(10, 12);
    return (y + "-" + m + "-" + d + " " + h + ":" + s);
}
//判断是否已收藏
function isCollect(uid, goods_id, token) {

    $.ajax({

        type: "POST",

        url: url + "users/goodsjudge",

        datType: "json",

        //async: "false",

        beforeSend: function (xhr) {

            xhr.setRequestHeader("TOKEN", token);

        },
        data: {
            "uid": uid,

            "goods_id": goods_id
        },
        success: function (data) {


            if (data.data.codes == "200") {//已收藏

                $('#heart').removeClass('heart').addClass('heartHover');

                $(".footer_tit").html("已收藏");

            } else {//未收藏

                $('#heart').removeClass('heartHover').addClass('heart');

                $(".footer_tit").html("收藏");

            }
        },
        error: function (info) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "请检查网络",
                    "VcWay": "ShowMessage"
                });

                //CallManPowerDetailsModel.jsCalliOSWithShowMessage("请检查网络");

            } else if (isMobile == 0) {

                window.android.toastMsg("请检查网络");
            }
        }
    })
}
//收藏和取消收藏 
function collect(uid, goods_id, number, that, token) {

    $.ajax({

        type: "POST",

        url: url + "users/productcollect",

        dataType: "json",

        //async: "false",

        beforeSend: function (xhr) {

            xhr.setRequestHeader("TOKEN", token);

        },
        data: {
            uid: uid,

            goods_id: goods_id,

            status: number
        },
        success: function (data) {

            if (data.codes == 200) {

                if (number == 200) {

                    that.removeClass("heartHover").addClass('heart');

                    $(".footer_tit").html("收藏");

                    if (isMobile == 1) {

                        window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                            "VcData": "取消收藏",
                            "VcWay": "ShowMessage"
                        });

                        //CallManPowerDetailsModel.jsCalliOSWithShowMessage("取消收藏");

                    } else if (isMobile == 0) {

                        window.android.toastMsg("取消收藏");

                    }
                } else if (number == 100) {

                    $(".modelBox").show();

                    $(".collection").show();

                    $(".collection .ok").click(function () {

                        $("#heart").removeClass("heart").addClass('heartHover');

                        $(".footer_tit").html("已收藏");

                        $(".collection").hide();

                        $(".modelBox").hide();
                    });


                }
            } else {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": "收藏失败",
                        "VcWay": "ShowMessage"
                    });

                    //CallManPowerDetailsModel.jsCalliOSWithShowMessage("收藏失败");

                } else if (isMobile == 0) {

                    window.android.toastMsg("收藏失败");
                }
            }
        },
        error: function (info) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "请检查网络",
                    "VcWay": "ShowMessage"
                });

                //CallManPowerDetailsModel.jsCalliOSWithShowMessage("请检查网络");

            } else if (isMobile == 0) {

                window.android.toastMsg("请检查网络");
            }

        }
    })
}
//加入购物车
function addCar(uid, goods_id, goods_number, start_time, end_time, goods_price, sum_total, meal_id, need_addr, token, time_long_id) {

    $.ajax({

        type: "POST",

        url: url + "users/addcart",

        dataType: "json",

        data: {

            "uid": uid,

            "goods_id": goods_id,

            "goods_number": goods_number,

            "start_time": start_time,

            "end_time": end_time,

            "goods_price": goods_price,

            "sum_total": sum_total,

            "meal_id": meal_id,

            "need_addr_id": need_addr,

            "time_long_id": time_long_id
        },
        beforeSend: function (xhr) {

            xhr.setRequestHeader("TOKEN", token);
        },
        success: function (data) {

            //alert(JSON.stringify(data))

            if (data.status == "SUCCESS") {

                if (isMobile == 1) {

                    //CallManPowerDetailsModel.jsCalliOSWithAddDetails();
                    //
                    //CallManPowerDetailsModel.jsCalliOSWithShowMessage("加入清单成功");

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({"VcWay": "AddDetails"});

                    var message = {

                        "VcData": "加入清单成功",

                        "VcWay": "ShowMessage"
                    };

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage(message);

                } else if (isMobile == 0) {

                    window.android.addShopCarSuccess("ok");

                    window.android.toastMsg("加入清单成功");
                }
            } else {
                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": "加入清单失败",
                        "VcWay": "ShowMessage"
                    });

                    //CallManPowerDetailsModel.jsCalliOSWithShowMessage("加入清单失败");

                } else if (isMobile == 0) {

                    window.android.toastMsg("加入清单失败");
                }
            }
        },
        error: function (info) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "请检查网络",
                    "VcWay": "ShowMessage"
                });

                //CallManPowerDetailsModel.jsCalliOSWithShowMessage("请检查网络");

            } else if (isMobile == 0) {

                window.android.toastMsg("请检查网络");
            }
        }

    })
}
//将判断库存的参数写在构造函数中
function Check(uid, goods_id, need_number, need_addr, meal_id, mealType, start_time, end_time) {

    this.uid = uid;

    this.goods_id = goods_id;

    this.need_address_id = need_addr;

    this.need_number = need_number;

    this.meal_type = mealType;

    this.start_time = start_time;

    this.end_time = end_time;

    this.meal_id = meal_id;
}
//检测是否有库存  点击立即购买订单判断，如果没有库存不能提交
function isCheck(dayta_json, token) {

    $.ajax({

        type: "POST",

        url: url + "users/goodsstock",

        data: dayta_json,

        dataType: "json",

        //async: "false",

        beforeSend: function (xhr) {

            xhr.setRequestHeader("TOKEN", token);

        },
        success: function (data) {

            if (data.codes != 200) {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": data.msg,
                        "VcWay": "ShowMessage"
                    });

                    //CallManPowerDetailsModel.jsCalliOSWithShowMessage(data.msg);

                } else if (isMobile == 0) {

                    window.android.toastMsg(data.msg);
                }
            }
            else {
                var json = {

                    "need_addr": String(dayta_json.need_address_id),

                    "TOKEN": token,

                    "uid": String($uid),

                    "goods_id": String($goods_id),

                    "meal": {

                        "name": $.trim($(".setMeal li.active").html()),

                        "data_type": $(".langTime li.active").data("type") || $(".price").html(),

                        "id": $(".setMeal li.active").attr("id"),

                        "mealType": String($(".setMeal li.active").data("mealtype")),

                        "time_long_id": $(".langTime li.active").attr("id"),

                        "time_long_name": $.trim($(".langTime li.active").html()),

                        "worth": $(".setMeal li.active").data("worth")
                    },
                    "startTime": $(".startDate").val(),

                    "endTime": $(".endDate").val(),

                    "money": $(".sub").html()
                };

                if (isMobile == 1) {

                    var message = {

                        "VcData": json,

                        "VcName": "ManPowerList",

                        "VcWay": "PushVCName"
                    };

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage(message);

                    //CallManPowerDetailsModel.jsCalliOSWithPushVCName({"VcData": json, "VcName": "ManPowerList"});

                } else if (isMobile == 0) {

                    //alert(JSON.stringify(json))

                    window.android.jumpToPersonOrder(JSON.stringify(json));
                }
            }
        },
        error: function (info) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "请检查网络",
                    "VcWay": "ShowMessage"
                });

                //CallManPowerDetailsModel.jsCalliOSWithShowMessage("请检查网络");

            } else if (isMobile == 0) {

                window.android.toastMsg("请检查网络");
            }
        }
    })
}
//获取人员服务商
function serviceId(goods_id, token, address, oldStartTime, oldEndTime) {

    $.ajax({

        type: "POST",

        url: url + "users/personservice",

        dataType: "json",

        //async: "false",

        beforeSend: function (xhr) {

            xhr.setRequestHeader("TOKEN", token);

        },
        data: {
            "goods_id": goods_id
        },

        success: function (data) {

            //console.log(data)

            if (data.codes == 200) {

                serverid = data.data.service_id;

            } else {

                serverid = null;
            }

            myAjax(goods_id, token, address, oldStartTime, oldEndTime)

        },
        error: function (info) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "请检查网络",
                    "VcWay": "ShowMessage"
                });

                //CallManPowerDetailsModel.jsCalliOSWithShowMessage("请检查网络");

            } else if (isMobile == 0) {

                window.android.toastMsg("请检查网络");
            }
        }
    });
}

function runa() {

    var time1 = $('.startDate').val();

    var time2 = $('.endDate').val();

    var mealId = $(".setMeal li.active").attr("id");

    var timestamp = Date.parse(new Date());//当前时间时间戳

    if (timeFormatDate(time1.replace(/-/g, "/")) && timeFormatDate(time2.replace(/-/g, "/"))) {

        if (time1 == "开始时间" || time2 == "结束时间") {

            if (time1 == "开始时间") {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": "请选择开始时间",
                        "VcWay": "ShowMessage"
                    });

                } else if (isMobile == 0) {

                    window.android.toastMsg("请选择开始时间");
                }
                return false;
            }
            if (time2 == "结束时间") {

                if (isMobile == 1) {

                    window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                        "VcData": "请选择结束时间",
                        "VcWay": "ShowMessage"
                    });

                } else if (isMobile == 0) {

                    window.android.toastMsg("请选择结束时间");
                }
                return false;
            }
        } else if (time1 >= time2) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "结束时间必须大于开始时间",
                    "VcWay": "ShowMessage"
                });

            } else if (isMobile == 0) {

                window.android.toastMsg("结束时间必须大于开始时间");

            }
            return false;

        } else if (new Date(time1.replace(/-/g, "/")).getTime() < timestamp) {

            if (isMobile == 1) {

                window.webkit.messageHandlers.CallManPowerDetailsModel.postMessage({
                    "VcData": "开始时间必须大于当前时间",
                    "VcWay": "ShowMessage"
                });

            } else if (isMobile == 0) {

                window.android.toastMsg("开始时间必须大于当前时间");

            }
            return false;
        }
        else {//有套餐 有时间 跳转下一页

            var check = new Check($uid, $goods_id, 1, address, mealId, $(".setMeal li.active").data("mealtype"), timeFormatDate(time1.replace(/-/g, "/")), timeFormatDate(time2.replace(/-/g, "/")));
            isCheck(check, token)
        }
    }
}
//这个方法是安卓和ios调用，收藏页面点击条目进入详情  判断是否为收藏状态
function changeCollectStatus(k) {

    var obj = $.parseJSON(k);

    isCollect(obj.uid, obj.goods_id, obj.TOKEN);

}
//获取当前月的天数，下月，下下月的总和
function mGetDate(n) {

    var date = new Date();

    var year = date.getFullYear();

    var month = date.getMonth() + n;

    if (month > 12) {

        year++;

        month = month - 12;
    }
    var d = new Date(year, month, 0);

    return d.getDate();
}


